package org.seed.rpc.example;

import org.seed.rpc.transfer.RpcConsumerProcessor;
import org.seed.rpc.transfer.RpcProtocol;
import org.smartboot.socket.transport.AioQuickClient;


public class ConsumerMain {

    public static void main(String[] args) throws Exception {

        for (int i = 0; i < 9999; i++) {
            long start = System.currentTimeMillis();
            RpcConsumerProcessor rpcConsumerProcessor = new RpcConsumerProcessor();
            AioQuickClient consumer = new AioQuickClient("127.0.0.1", 9999, new RpcProtocol(), rpcConsumerProcessor);
            consumer.start();
            Calculate demoApi = rpcConsumerProcessor.getObject(Calculate.class);
            System.out.println("1+2=" + demoApi.add(1, 2));
            System.out.println("127+256=" + demoApi.add(127, 256));
            System.out.println("99+1=" + demoApi.add(99, 1));
            long end = System.currentTimeMillis();
            consumer.shutdown();
            System.out.println("3个加法运算使用耗时: " + (end - start) + " ms");
        }



    }
}
